-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use register_dynamic for merging #18028
base: main
Are you sure you want to change the base?
Use register_dynamic for merging #18028
Conversation
No migration guide for bug fixes in general :) |
) in required_components | ||
.0 | ||
.iter() | ||
.map(|(id, req)| (*id, req.clone())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to avoid cloning here, but I don't see a way to do that without making register_dynamic's signature worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I will need to extend functionality here a tiny bit to work better with RequiredComponentsMut
from #17871. I think I can avoid cloning on that branch, but over here, I was just focused on fixing the bug. If preferred, I can go ahead and add that extra functionality here, but the extra complexity won't really be used until #17871.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, don't worry about it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test: that clearly demonstrated the problem to me.
Objective
I found a bug while working on #17871. When required components are registered, ones that are more specific (smaller inheritance depth) are preferred to others. So, if a ComponentA is already required, but it is registered as required again, it will be updated if and only if the new requirement has a smaller inheritance depth (is more specific). However, this logic was not reflected in merging
RequriedComponents
s together. Hence, for complicated requirement trees, the wrong initializer could be used.Solution
Re-write merging to work by extending the collection via
require_dynamic
instead of blindly combining the inner storage.Testing
I created this test to ensure this bug doesn't creep back in. This test fails on main, but passes on this branch.
Note that when the inheritance depth is 0 (Like if there were no middle man above), the order of the components in the bundle still matters.
Does this need a Migration Guide?
I don't believe this needs a migration guide since it's a bug fix, but it could break user's complex requirement tree if they depended on the bug. If I should add this, let me know.